//
//  MPTLiveMeCell.m
//  MPTLive
//
//  Created by caixun on 16/1/27.
//  Copyright © 2016年 Jeakin. All rights reserved.
//

#import "MPTLiveMeCell.h"

#define CellH (52)


@interface MPTLiveMeCell ()


// cell的icon图片
@property (nonatomic, strong) UIImageView *imgvIcon;
// cell的标题文字
@property (nonatomic, strong) UILabel *labelTitle;
// cell右侧的数字
@property (nonatomic, strong) UILabel *labelNum;
// cell右侧的箭头
@property (nonatomic, strong) UIImageView *imgvJianTou;


@end


@implementation MPTLiveMeCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self initCellContent];
    }
    return self;
    
}

- (void)initCellContent
{
    // 创建 cell的icon图片
    self.imgvIcon = [[UIImageView alloc] initWithFrame:CGRectMake(15, 15, 22, 22)];
    [self.contentView addSubview:self.imgvIcon];
    
    // 创建 cell的标题文字
    self.labelTitle = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.imgvIcon.frame)+10,
                                                                0,
                                                                100,
                                                                CellH)];
    self.labelTitle.textColor = RGBAllColor(0x282828);
    [self.labelTitle setTextAlignment:NSTextAlignmentLeft];
    [self.contentView addSubview:self.labelTitle];
    
    // 创建 cell右侧的箭头
    self.imgvJianTou = [[UIImageView alloc] initWithFrame:CGRectMake(screenW-15-8,
                                                                     (CellH-14)/2,
                                                                     8,
                                                                     14)];
    
    self.imgvJianTou.image =[UIImage imageNamed:@"JianTou"];
    [self.contentView addSubview:self.imgvJianTou];
    
    // 创建 cell右侧的数字
    self.labelNum = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_labelTitle.frame),
                                                              0,
                                                              CGRectGetMidX(_imgvJianTou.frame) - CGRectGetMaxX(_labelTitle.frame) - 10,
                                                              52)];
    self.labelNum.textColor = RGBAllColor(0x666666);
    self.labelNum.font = [UIFont systemFontOfSize:13.0f];
    self.labelNum.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:self.labelNum];
}


- (void)setDataWithDic:(NSDictionary *)dic indexpath:(NSIndexPath *)indexpath
{
    if (indexpath.section == 0)
    {
        if (indexpath.row == 0)
        {
            self.imgvIcon.image = [UIImage imageNamed:@"yanjing"];
            _labelTitle.text = @"关注";
            _labelNum.text = [dic[@"follow"] description];
        }
        else
        {
            self.imgvIcon.image = [UIImage imageNamed:@"fenshiren"];
            _labelTitle.text = @"粉丝";
            _labelNum.text = [dic[@"fans"] description];
        }
        
    }
    else
    {
        /// 设置
        _labelTitle.text = @"设置";
        self.imgvIcon.image = [UIImage imageNamed:@"shezhitupian"];
    }
}

+ (float)getCellH
{
    return 52;
}


@end
